package com.sumer.psychology.common.application;

import com.sumer.psychology.common.BusinessException;

/**
 * 公共的查询逻辑
 * <p/>
 * Created by twer on 15/3/14.
 */
public class CommonQueryApplicationService {
    private static final String BLOG = "blog";
    private static final String MICRO_BLOG = "microblog";
    private static final String PHOTO = "photo";
    private static final String SHARING = "sharing";

    /**
     * 根据业务id，获得作者
     *
     * @param businessType business type
     * @return author
     */
    public String author(String businessType, String businessId) {
        switch (businessType) {
            case BLOG:
                return ApplicationServiceRegistry.blogQueryApplicationService().findAuthorId(businessId);
            case MICRO_BLOG:
                return ApplicationServiceRegistry.microBlogQueryApplicationService().findAuthorId(businessId);
            case PHOTO:
                return ApplicationServiceRegistry.photoQueryApplicationService().findAuthorId(businessId);
            case SHARING:
                return ApplicationServiceRegistry.sharedResourceQueryApplicationService().findAuthorId(businessId);
            default:
                throw new BusinessException("业务异常，无法取得作者");
        }
    }

}
